@extends('admin.layout')
@section('title','编辑专家')
@section('content1')
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <script type="text/javascript" src="/res/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="/res/js/ueditor/ueditor.all.js"></script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/res/js/ueditor/lang/zh-cn/zh-cn.js"></script>
    <style type="text/css">
        div{
            width:100%;
        }
    </style>

<div class="app_content_div" id="app_content_div_301Index">
    <h3>编辑专家</h3>
</div>
<form class="form-horizontal"  method="post" action="/adm/expert/edit/{{$oExpert->id}}">
    @csrf
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label"><span style="color:red;">*</span>姓名</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="name" name="name" value="{{$oExpert->name}}">
        </div>
    </div>
    <div class="form-group">
        <label for="thumb" class="col-sm-2 control-label"><span style="color:red;">*</span>缩略图</label>
        <div class="col-sm-10">
            <input  id="thumb" name="thumb" type="file" onchange="saveThumb()"/>
            <input type="hidden" class="form-control" id="photo" name="photo"  value="{{$oExpert->photo}}">
            <img style="width:160px;height:200px;" alt="" id="thumb" src="{{$oExpert->photo}}"/>
        </div>
    </div>
    <div class="form-group">
        <label for="department" class="col-sm-2 control-label"><span style="color:red;">*</span>科室</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="department" name="department"  value="{{$oExpert->department}}">
        </div>
    </div>
    <div class="form-group">
        <label for="chenghao" class="col-sm-2 control-label"><span style="color:red;">*</span>职称</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="chenghao" name="chenghao" value="{{$oExpert->chenghao}}">
        </div>
    </div>
    <div class="form-group">
        <label for="job" class="col-sm-2 control-label"><span style="color:red;">*</span>职务</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="job" name="job" value="{{$oExpert->job}}">
        </div>
    </div>
    <div class="form-group">
        <label for="hospital" class="col-sm-2 control-label"><span style="color:red;">*</span>医院</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="hospital" name="hospital"  value="{{$oExpert->hospital}}">
        </div>
    </div>
    <div class="form-group" >
        <label for="introduction" class="col-sm-2 control-label"><span style="color:red;">*</span>简介</label>
        <div class="col-sm-10">
            <script id="introduction" name="introduction" type="text/plain"> {{$oExpert->introduction}}</script>
            <script type="text/javascript">
                var ue = UE.getEditor('introduction');
            </script>
        </div>
    </div>
    <div class="form-group" >
        <label for="education" class="col-sm-2 control-label"><span style="color:red;">*</span>接受教育</label>
        <div class="col-sm-10">
            <script id="education" name="education" type="text/plain"> {{$oExpert->education}}</script>
            <script type="text/javascript">
                var ue = UE.getEditor('education');
            </script>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <input name="dosubmit" type="button" value="提交" class="btn_p" onclick="tijiao1()" >
        </div>
    </div>
</form>
<script>


    function tijiao1() {
        var name = $("#name").val();
        var department = $("#department").val();
        var chenghao = $("#chenghao").val();
        var job = $("#job").val();
        var hospital = $("#hospital").val();
        var introduction = ue.getContentTxt('introduction');
        var education = ue.getContentTxt('education');
        // var photo = $('#photo')[0].files[0];
        var _token ="{{@csrf_token()}}";
        $.post('/adm/expert/edit/{{$oExpert->id}}',
            {
                'name':name,
                'department':department,
                'chenghao':chenghao,
                'job':job,
                'hospital':hospital,
                'introduction':introduction,
                'education':education,
                '_token':_token
            },
            function (data){
                if(data.success){
                    alert("已完成");
                    location.href="/adm/expert";
                }
                else{
                    alert(data.msg);
                }
            },'json');
    }
</script>

@endsection
